package day13;

import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;

public class TestHashMap {
	public static void main(String[] args) {
		HashMap hm = new HashMap();
		hm.put(new Integer(1), "aaa");
		hm.put(2, "bbb");
		hm.put(3, "ccc");
		System.out.println(hm.size());
		Object o1 = hm.get(new Integer(1));
		System.out.println(o1);
		System.out.println(hm.size());
		//Object o2 = hm.remove(2);
		//System.out.println(o2);
		System.out.println(hm.size());
		System.out.println(hm.containsKey(2));
		System.out.println(hm.containsValue("bbb"));
		System.out.println("============================");
		Collection cs = hm.values();
		Iterator it = cs.iterator();
		while (it.hasNext()) {
			String s = (String) it.next();
			System.out.println(s);
		}
		Set set = hm.keySet();
		Iterator it1 = set.iterator();
		while (it1.hasNext()) {
			Integer i = (Integer) it1.next();
			Object value = hm.get(i);
			System.out.println(i+":"+value);
		}
	}
}
